GBML manual / Audio

sound_play

Plays a sound effect once, at volume (0..1) times the current sound_gain() multiplier. Leave volume out for full volume.

Syntax

sound_play(s, volume = 1)

Arguments

NameType
ssound
volumereal (can be left out; then it is 1)

Returns

Nothing.

Description

Plays a sound effect once, at volume (0..1; leave it out for full volume, sound_play(snd_doc_beep)) times whatever sound_gain is currently set to - a project's own "SFX volume" setting applies automatically to every call, never something each sound_play has to account for itself. Nothing about calling this stops an earlier instance of the same sound still playing; two overlapping calls play as two overlapping sounds. It plays either kind of sound the same way: a recording, or a tiny chip sound made in the Music tab's sound effects generator (a chip sound played again starts over, and a third buzzing chip sound takes over the oldest one).

Example

sound_play(snd_doc_beep, 1);

Plays the sound once at full volume (before sound_gain's own multiplier is applied) - the usual shape for a one-shot effect like a pickup or a hit.

On the GBA

volume can be left out: sound_play(snd_hit) is sound_play(snd_hit, 1), full volume.

See also: sound_stopsound_playing